// 组件props

import React from 'react'
import ReactDOM from 'react-dom'

// 父组件
class Parent extends React.Component {
  state = {
    lastName: '王'
  }

  render() {
    return (
      <div style={{ backgroundColor: 'pink' }}>
        <h1>我是父组件：</h1>

        <Child name={this.state.lastName} />
      </div>
    )
  }
}

// 子组件
const Child = props => {
  console.log('子组件接收到：', props)
  return (
    <div>
      <span>我是子组件，我姓：{props.name}</span>
    </div>
  )
}

// 渲染
ReactDOM.render(<Parent />, document.getElementById('root'))
